//
//  UIAlertController+Extension.m
//  wordGif
//
//  Created by Seven on 16/8/6.
//  Copyright © 2016年 Seven. All rights reserved.
//

#import "UIAlertController+Extension.h"

@implementation UIAlertController (Extension)

+(UIAlertController *)alertControllerWithTitle:(NSString *)title message:(NSString *)message leftTitle:(NSString *)leftTitle rightTitle:(NSString *)rightTitle rightHandler:(NSStringBlock)rightBlock  leftHandler:(NSStringBlock)leftBlock {
    
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
                                                                             message:message
                                                                      preferredStyle:UIAlertControllerStyleAlert];
    
    
    //添加取消到UIAlertController中
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:leftTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (leftBlock) {
            leftBlock();
        }
    }];
    
    [alertController addAction:cancelAction];
    
    
    //添加确定到UIAlertController中
    UIAlertAction *OKAction = [UIAlertAction actionWithTitle:rightTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (rightBlock) {
            rightBlock();
        }
        //响应回调
    }];
    
    
    [alertController addAction:OKAction];
    
    return alertController;
}

+(UIAlertController *)alertControllerWithTitle:(NSString *)title message:(NSString *)message oneTitle:(NSString *)oneTitle  oneHandler:(NSStringBlock)oneHandler {
    
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
                                                                             message:message
                                                                      preferredStyle:UIAlertControllerStyleAlert];
    

    //添加确定到UIAlertController中
    UIAlertAction *OKAction = [UIAlertAction actionWithTitle:oneTitle style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        if (oneHandler) {
            oneHandler();
        }
        //响应回调
    }];
    
    
    [alertController addAction:OKAction];
    
    return alertController;
}

@end
